﻿using DomainService.IService;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DomainService.Service
{
    /// <summary>
    /// 缓存服务接口实现
    /// </summary>
    public class MemoryCacheService : IMemoryCacheService
    {
        #region 构造实列化

        /// <summary>
        /// 缓存接口
        /// </summary>
        private readonly IMemoryCache _memoryCache;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="memoryCache"></param>
        public MemoryCacheService(IMemoryCache memoryCache)
        {
            _memoryCache = memoryCache;
        }

        #endregion

        #region 常量

        // 创建缓存选项
        private MemoryCacheEntryOptions cacheOptions = new MemoryCacheEntryOptions()
            .SetAbsoluteExpiration(TimeSpan.FromHours(24)) // 24小时后绝对过期
            .SetSlidingExpiration(TimeSpan.FromHours(1))    // 如果1小时内未被访问则过期
            .SetPriority(CacheItemPriority.High);            // 高优先级（内存不足时最后被移除）

        #endregion

        #region 接口实现



        #endregion

    }
}
